<template>
  <div v-loading="loading">
    <el-tabs v-model="activeName">
      <el-tab-pane :label="$t('分配详情')" name="fp">
        <fundFpMain ref="fundFpMain" />
      </el-tab-pane>
      <el-tab-pane v-if="showNotice" :label="$t('通知详情')" name="notice">
        <emailReviewForm ref="emailReviewForm" :show-btn-status="false" :other-btn-hide="true" />
      </el-tab-pane>
    </el-tabs>
  </div>
</template>

<script>
import fundFpMain from '@/views/fund/fp/fundFpMainForm'
import emailReviewForm from '@/views/fund/lpBase/lp/EmailReviewForm'
import { getFundFpMain } from '@/api/fund/fp/fundFpMain'
export default {
  components: {
    fundFpMain,
    emailReviewForm
  },
  props: {},
  data() {
    return {
      // 遮盖层
      loading: false,
      showNotice: true,
      activeName: 'fp',
      otherBtnHide: false
    }
  },
  watch: {},
  created() {
    this.$bus.$emit('async_done')
  },
  methods: {
    init(data) {
      this.$refs.fundFpMain.init(data)
      if (data && data.id) {
        this.loading = true
        getFundFpMain(data.id).then(response => {
          if (response.data && response.data.announcementId) {
            this.$refs.emailReviewForm.init({ id: response.data.announcementId })
          } else {
            this.showNotice = false
          }
          this.$nextTick(() => {
            this.$res.fundFpMain.otherBtnHide = this.otherBtnHide
          })
          this.loading = false
        }).catch(() => {
          this.loading = false
          this.showNotice = false
        })
      }
    },
    submitForm(type) {
      return new Promise((resolve, reject) => {
        this.$refs.fundFpMain.submitForm(type).then(data => {
          resolve(data)
        }).catch(e => {
          reject(e)
        })
      })
    }
  }
}
</script>

<style scoped>

</style>
